import 'package:flutter_test/flutter_test.dart';
import 'package:forme/models/todo.dart';

void main() {
  group('Todo Model Tests', () {
    test('Todo creation should work correctly', () {
      final todo = Todo.create(
        id: 'test-id',
        title: 'Test Todo',
        description: 'Test Description',
        priority: 1,
      );

      expect(todo.id, 'test-id');
      expect(todo.title, 'Test Todo');
      expect(todo.description, 'Test Description');
      expect(todo.priority, 1);
      expect(todo.isCompleted, false);
      expect(todo.priorityText, '高');
    });

    test('Todo JSON serialization should work', () {
      final todo = Todo.create(
        id: 'test-id',
        title: 'Test Todo',
        description: 'Test Description',
        priority: 1,
      );

      final json = todo.toJson();
      expect(json['id'], 'test-id');
      expect(json['title'], 'Test Todo');
      expect(json['description'], 'Test Description');
      expect(json['priority'], 1);
      expect(json['isCompleted'], false);

      final todoFromJson = Todo.fromJson(json);
      expect(todoFromJson.id, todo.id);
      expect(todoFromJson.title, todo.title);
      expect(todoFromJson.description, todo.description);
      expect(todoFromJson.priority, todo.priority);
      expect(todoFromJson.isCompleted, todo.isCompleted);
    });

    test('Todo copyWith should work correctly', () {
      final todo = Todo.create(
        id: 'test-id',
        title: 'Test Todo',
        priority: 1,
      );

      final updatedTodo = todo.copyWith(
        title: 'Updated Todo',
        isCompleted: true,
      );

      expect(updatedTodo.id, 'test-id');
      expect(updatedTodo.title, 'Updated Todo');
      expect(updatedTodo.isCompleted, true);
      expect(updatedTodo.priority, 1);
    });
  });
}